home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Tools / Win95 Secrets / SETUP.Z / WIN95MEM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-19  |  2.9 KB  |  84 lines

  1. //=================================
  2. // WIN95MEM - Matt Pietrek 1995
  3. // FILE: WIN95MEM.C
  4. //=================================
  5. #include <windows.h>
  6. #include "win95mem.h"
  7.  
  8. // The DemandInfoStruc struct below is excerpted from the VMM.H file
  9. // in the Windows 95 DDK
  10.  
  11. struct DemandInfoStruc {
  12.     ULONG DILin_Total_Count;    /* # pages in linear address space */
  13.     ULONG DIPhys_Count;         /* Count of phys pages */
  14.     ULONG DIFree_Count;         /* Count of free phys pages */
  15.     ULONG DIUnlock_Count;       /* Count of unlocked Phys Pages */
  16.     ULONG DILinear_Base_Addr;   /* Base of pageable address space */
  17.     ULONG DILin_Total_Free;     /* Total Count of free linear pages */
  18.  
  19.     /*
  20.      *  The following 5 fields are all running totals, kept from the time
  21.      *  the system was started
  22.      */
  23.     ULONG DIPage_Faults;        /* total page faults */
  24.     ULONG DIPage_Ins;           /* calls to pagers to page in a page */
  25.     ULONG DIPage_Outs;          /* calls to pagers to page out a page*/
  26.     ULONG DIPage_Discards;      /* pages discarded w/o calling pager */
  27.     ULONG DIInstance_Faults;    /* instance page faults */
  28.  
  29.     ULONG DIPagingFileMax;      /* maximum # of pages that could be in paging file */
  30.     ULONG DIPagingFileInUse;    /* # of pages of paging file currently in use */
  31.  
  32.     ULONG DICommit_Count;       /* Total committed memory, in pages */
  33.  
  34.     ULONG DIReserved[2];        /* Reserved for expansion */
  35. };
  36.  
  37. DWORD WINAPI VxDCall2( DWORD service_number, DWORD, DWORD );
  38.  
  39. void Handle_WM_TIMER(HWND hWndDlg, WPARAM wParam, LPARAM lParam)
  40. {
  41.     struct DemandInfoStruc dis;
  42.     char szBuffer[256];
  43.  
  44.     // Demonstrate calling a Win32 VxD service (in this case, the
  45.     // _GetDemandPageInfo service.
  46.     VxDCall2( 0x0001001E, (DWORD)&dis, 0 );
  47.     
  48.     wsprintf(szBuffer, "Comm: %uK", dis.DICommit_Count * 4);
  49.     SetDlgItemText( hWndDlg, IDC_TEXT_commited, szBuffer );
  50.  
  51.     wsprintf(szBuffer, "Phys: %uK", dis.DIPhys_Count * 4);
  52.     SetDlgItemText( hWndDlg, IDC_TEXT_physical, szBuffer );
  53.  
  54.     wsprintf(szBuffer, "%u%%",
  55.                 (dis.DICommit_Count * 100) / dis.DIPhys_Count);
  56.     SetDlgItemText( hWndDlg, IDC_TEXT_percentage, szBuffer );
  57. }
  58.  
  59. BOOL CALLBACK Win95MemDlgProc(HWND hWndDlg, UINT msg,
  60.                               WPARAM wParam, LPARAM lParam)
  61. {
  62.     switch ( msg )
  63.     {
  64.         case WM_INITDIALOG:
  65.             SetTimer( hWndDlg, 0, 1000, 0 ); return TRUE;
  66.         case WM_TIMER:
  67.             Handle_WM_TIMER(hWndDlg, wParam, lParam); return TRUE;
  68.         case WM_CLOSE:
  69.             KillTimer(hWndDlg, 0);
  70.             EndDialog(hWndDlg, 0);
  71.             return FALSE;
  72.     }
  73.     
  74.     return FALSE;
  75. }
  76.  
  77. int APIENTRY WinMain( HANDLE hInstance, HANDLE hPrevInstance,
  78.                         LPSTR lpszCmdLine, int nCmdShow )
  79. {
  80.     DialogBox(hInstance, "WIN95MEM_DLG", 0, (DLGPROC)Win95MemDlgProc );
  81.     return 00;
  82. }
  83.  
  84.